package androidx.transition;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.core.view.ViewCompat;
import androidx.transition.Transition.b;
import o.fx;
import o.nq;
import o.ns;
import o.nx;
import o.oi;

public class Fade extends Visibility {

    static class a extends AnimatorListenerAdapter {
        private final View ˎ;
        private boolean ॱ = false;

        a(View view) {
            this.ˎ = view;
        }

        public void onAnimationStart(Animator animator) {
            if (ViewCompat.ॱᐝ(this.ˎ) && this.ˎ.getLayerType() == 0) {
                this.ॱ = true;
                this.ˎ.setLayerType(2, null);
            }
        }

        public void onAnimationEnd(Animator animator) {
            oi.ˋ(this.ˎ, 1.0f);
            if (this.ॱ) {
                this.ˎ.setLayerType(0, null);
            }
        }
    }

    public Fade(int i) {
        ˋ(i);
    }

    public Fade(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, ns.ʼ);
        ˋ(fx.ˊ(obtainStyledAttributes, (XmlResourceParser) attributeSet, "fadingMode", 0, ʻॱ()));
        obtainStyledAttributes.recycle();
    }

    public void ˋ(@NonNull nx nxVar) {
        super.ˋ(nxVar);
        nxVar.ˊ.put("android:fade:transitionAlpha", Float.valueOf(oi.ॱ(nxVar.ॱ)));
    }

    private Animator ˊ(final View view, float f, float f2) {
        if (f == f2) {
            return null;
        }
        oi.ˋ(view, f);
        Animator ofFloat = ObjectAnimator.ofFloat(view, oi.ॱ, new float[]{f2});
        ofFloat.addListener(new a(view));
        ˊ(new nq(this) {
            final /* synthetic */ Fade ˋ;

            public void ˋ(@NonNull Transition transition) {
                oi.ˋ(view, 1.0f);
                oi.ˊ(view);
                transition.ॱ((b) this);
            }
        });
        return ofFloat;
    }

    public Animator ˏ(ViewGroup viewGroup, View view, nx nxVar, nx nxVar2) {
        float f = 0.0f;
        float ˋ = ˋ(nxVar, 0.0f);
        if (ˋ != 1.0f) {
            f = ˋ;
        }
        return ˊ(view, f, 1.0f);
    }

    public Animator ˊ(ViewGroup viewGroup, View view, nx nxVar, nx nxVar2) {
        oi.ˎ(view);
        return ˊ(view, ˋ(nxVar, 1.0f), 0.0f);
    }

    private static float ˋ(nx nxVar, float f) {
        if (nxVar == null) {
            return f;
        }
        Float f2 = (Float) nxVar.ˊ.get("android:fade:transitionAlpha");
        if (f2 != null) {
            return f2.floatValue();
        }
        return f;
    }
}
